const { paramSerialize, getUrlParams } = require('../../utils/util.js')
// index.js
const app = getApp()
Page({
  data: {
    jumpType: {
      sign: "/pages/my-exam-list/my-exam-list"
    },
    filterName: ['sign']
  },
  /*
  * jumpUrl跳转地址
  * needValid 需要验证用户身份 也就是sapid
  * params 其他参数
  */
  onLoad(query) {
    // 二维码进入
    if (query.q) {
      const q = decodeURIComponent(query.q)
      const {jumpUrl,needValid=true,...params} = getUrlParams(q);

      if (this.data.filterName.includes(jumpUrl) && (needValid ? wx.getStorageSync('userinfo').staffId : true)) {
        wx.reLaunch({
          url: `${this.data.jumpType[jumpUrl]}?params=${encodeURIComponent(JSON.stringify(params))}`
        });
      }
      else {
        wx.reLaunch({
          url: `/pages/login/index?url=${this.data.jumpType[jumpUrl]}&params=${encodeURIComponent(JSON.stringify(params))}`,
        });
      }
    }

    // 菊花码查询
    if (query.scene) {
      console.log('query',query)
      wx.reLaunch({
        url: `/pages/my-exam-index/my-exam-index?id=${query.scene}`
      });
    }


  },
})